package com.dianban.service.impl;


import com.dianban.dao.JwShoproUserAddressDao;
import com.dianban.entity.JwShoproUserAddress;
import com.dianban.service.JwShoproUserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
@Transactional(readOnly = true)
public class JwShoproUserAddressServiceImpl implements JwShoproUserAddressService {

    @Autowired
    private JwShoproUserAddressDao jwShoproUserAddressDao;


    @Override
    public List<JwShoproUserAddress> findList(Long userId) {
        return jwShoproUserAddressDao.findList(userId);
    }

    @Override
    @Transactional(readOnly = false)
    public void updateIsDefault(String isDefault, Long userId) {
        jwShoproUserAddressDao.updateIsDefault(isDefault, userId);
    }

    @Override
    @Transactional(readOnly = false)
    public void insert(JwShoproUserAddress jwShoproUserAddress) {
        jwShoproUserAddress.setCreatetime(System.currentTimeMillis()/1000);
        jwShoproUserAddressDao.insert(jwShoproUserAddress);
    }

    @Override
    public JwShoproUserAddress findById(String id) {
        return jwShoproUserAddressDao.findById(id);
    }

    @Override
    @Transactional(readOnly = false)
    public void update(JwShoproUserAddress jwShoproUserAddress) {
        jwShoproUserAddress.setUpdatetime(System.currentTimeMillis()/1000);
        jwShoproUserAddressDao.update(jwShoproUserAddress);
    }

    @Override
    @Transactional(readOnly = false)
    public void deleteById(String id) {
        JwShoproUserAddress jwShoproUserAddress = jwShoproUserAddressDao.findById(id);
        jwShoproUserAddress.setDeletetime(System.currentTimeMillis()/1000);
        jwShoproUserAddressDao.deleteById(jwShoproUserAddress);
    }
}
